<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends CommonController {
    public function index(){

    	//查询产品
        $mod = M('goods');
        //查询定制产品
        $customization = $mod->field('id,gname,pic,description')->where('customization=1')->order('addtime desc')->limit(4)->select();
        //查询男款产品
        $male = $mod->field('id,gname,pic,description')->where('gender=1')->order('addtime desc')->limit(4)->select();
        //查询女款产品
        $female = $mod->field('id,gname,pic,description')->where('gender=0')->order('addtime desc')->limit(4)->select();
        //查询小孩产品
        $boys = $mod->field('id,gname,pic,description')->where('adult=0')->order('addtime desc')->limit(4)->select();

    	//查询新闻
    	$news = M('news')->order('addtime desc')->limit(3)->select();
    	foreach($news as $k=>$v)
    	{
    		$news[$k]['description'] = htmlspecialchars_decode($v['description']);
    	}

        $this->assign('customization',$customization);
        $this->assign('male',$male);
        $this->assign('female',$female);
        $this->assign('boys',$boys);
    	$this->assign('news',$news);
    	$this->assign('title','首页');
        
        $this->display('index');
    }
}